n = int(input())
l = []
for i in range(1,n+1):
    x,y,z = map(int,input().split())
    f = [i,x,y,z]
    l.append(f)
l.sort(key=lambda x:(x[1]+x[2]+x[3],x[1],-x[0]),reverse=True)
for j in range(5):
    print(l[j][0],(sum(l[j])-l[j][0]))